package client;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class mainClientSocket {

	public static void main(String [] args) throws IOException{
		int port=2000;
		String host="localhost";
		
		//Creo il socket
		Socket socket=new Socket(host,port);
		
		//Stream Handler
		BufferedReader input=new BufferedReader(new InputStreamReader(socket.getInputStream()));
		BufferedWriter output=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
		
		//Reader from Sys.in
		BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			System.out.print("Client send: ");
			String message=in.readLine();
			output.write(message);
			output.newLine();
			output.flush();
			System.out.println("server: " + input.readLine());
			
			
		}
		
		
		
	}
	
}
